/**
 * 
 */
package com.tvshows.front.view.recap;

import org.eclipse.swt.SWT;
import org.eclipse.swt.layout.FormAttachment;
import org.eclipse.swt.layout.FormData;
import org.eclipse.swt.layout.FormLayout;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Sash;
import org.eclipse.swt.widgets.Shell;

import com.tvshows.front.ui.recap.RecapUI;

/**
 * @author tMidy
 */
public class RecapView
    extends Composite
    implements RecapUI
{

    private FormData buttonGroupData;

    private FormData listData;

    private final TableCompositeRecapView tableComposite;

    private UpsideCompositeRecapView upsideComposite;

    /**
     * Constructeur
     */
    public RecapView( Shell shell, int style )
    {
        super( shell, style );
        this.setLayout( new FormLayout() );
        tableComposite = new TableCompositeRecapView( this, SWT.NONE );
        initFormData();
        initComposites();
    }

    /**
     * @see com.tvshows.front.ui.recap.RecapUI#initFormData()
     */
    @Override
    public void initFormData()
    {
        Sash recapSash = new Sash( this, SWT.HORIZONTAL );
        FormData sashData = new FormData();
        sashData.left = new FormAttachment( 0, 0 );
        sashData.bottom = new FormAttachment( 20, 0 );
        sashData.right = new FormAttachment( 100, 0 );
        buttonGroupData = new FormData();
        buttonGroupData.left = new FormAttachment( 0, 0 );
        buttonGroupData.right = new FormAttachment( 100, 0 );
        buttonGroupData.top = new FormAttachment( 0, 0 );
        buttonGroupData.bottom = new FormAttachment( recapSash, 0 );
        listData = new FormData();
        listData.left = new FormAttachment( 0, 0 );
        listData.right = new FormAttachment( 100, 0 );
        listData.top = new FormAttachment( recapSash, 0 );
        listData.bottom = new FormAttachment( 100, 0 );
        recapSash.setLayoutData( sashData );
    }

    /**
     * Initializes the form datas
     */
    @Override
    public void initComposites()
    {
        upsideComposite = new UpsideCompositeRecapView( this, SWT.BORDER );
        tableComposite.setLayoutData( listData );
        upsideComposite.setLayoutData( buttonGroupData );

        this.layout();
        this.update();
    }

    /**
     * @see com.tvshows.front.ui.recap.RecapUI#getTableComposite()
     */
    @Override
    public TableCompositeRecapView getTableComposite()
    {
        return tableComposite;
    }

    /**
     * @see com.tvshows.front.ui.recap.RecapUI#getUpsideComposite()
     */
    @Override
    public UpsideCompositeRecapView getUpsideComposite()
    {
        return upsideComposite;
    }

    /**
     * @see com.tvshows.front.ui.recap.RecapUI#setLayoutData(org.eclipse.swt.layout.FormData)
     */
    public void setLayoutData( FormData recapData )
    {
        super.setLayoutData( recapData );
    }
}
